﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Cms/Admin.Master" AutoEventWireup="true"
    CodeBehind="SeriesMan.aspx.cs" Inherits="Aij1.Cms.SeriesMan" %>

<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Data.Linq" TagPrefix="cc1" %>
<%@ Register Assembly="DevExpress.Xpo.v13.1.Web, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Xpo" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxTreeList.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeList" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .templateTable
        {
            border-collapse: collapse;
            width: 100%;
        }
        .templateTable td
        {
            border: solid 1px #C2D4DA;
            padding: 3px;
        }
        .templateTable td.value
        {
            font-weight: bold;
        }
    </style>
    <script type="text/javascript">
        var catId;
        function tree_NodeClick(s, e) {
            catId = e.nodeKey;
            document.getElementById("hdnCategoryId").value = catId;
            grid.PerformCallback();
        }

        function btnNew_Click(s, e) {
            location = 'Series.aspx?CatId=' + tree.GetFocusedNodeKey();
        }

        function btnDelete_Click(s, e) {
            if (confirm("确认删除?")) {
                grid.PerformCallback('del:0');
            }
        }

        function btnSetTop_Click(s, e) {
            if (confirm("确认置顶?")) {
                grid.PerformCallback('settop:0');
            }
        }

        function btnCancelTop_Click(s, e) {
            if (confirm("确认取消置顶?")) {
                grid.PerformCallback('canceltop:0');
            }
        }

        function editAlbum(albumId) {
            location = 'Series.aspx?Id=' + albumId;
        }
        function editInfo(albumId) {
            grid.StartEditRowByKey(albumId);
        }

        function setTop(selkeys) {
            grid.PerformCallback('settop:' + selkeys);
        }

        function cancelTop(selkeys) {
            grid.PerformCallback('canceltop:' + selkeys);
        }

        function delAlbum(albumId) {
            if (confirm("确认删除?")) {
                grid.DeleteRowByKey(albumId);
            }
        }
        function selectAll(s, e) {
            var ids = document.getElementsByName("chkIds");
            for (var i = 0; i < ids.length; i++) {
                ids[i].checked = s.GetChecked();
            }
        }

        function chk_Changed(s) {
            var id = s.id.replace('chk', '');
            if (s.checked) {
                grid.SelectRowsByKey(id);
            }
            else {
                grid.UnselectRowsByKey(id);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="CT2" ContentPlaceHolderID="PH" runat="server">
    <input type="hidden" value="" id="hdnCategoryId" name="CategoryId" />
    <table class="style1">
        <tr>
            <td>
            </td>
            <td>
                <table class="style1">
                    <tr>
                        <td width="120">
                            <dx:ASPxButton ID="btnNew" runat="server" Text="新增" AutoPostBack="False">
                                <ClientSideEvents Click="btnNew_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="120">
                            <dx:ASPxButton ID="btnDelete" runat="server" Text="批量删除" AutoPostBack="False" ClientInstanceName="btnDelete">
                                <ClientSideEvents Click="btnDelete_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="120">
                            <dx:ASPxButton ID="btnSetTop" runat="server" Text="批量置顶" AutoPostBack="False" ClientInstanceName="btnSetTop">
                                <ClientSideEvents Click="btnSetTop_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnCancelTop" runat="server" Text="批量取消" AutoPostBack="False"
                                ClientInstanceName="btnCancelTop">
                                <ClientSideEvents Click="btnCancelTop_Click" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr valign="top">
            <td width="160">
                <dx:ASPxTreeList ID="TL" runat="server" AutoGenerateColumns="False" ClientInstanceName="tree"
                    Width="100%" KeyFieldName="Oid" ParentFieldName="ParentId!Key" DataSourceID="XD2">
                    <Columns>
                        <dx:TreeListTextColumn Caption="栏目" FieldName="Title" VisibleIndex="0">
                        </dx:TreeListTextColumn>
                    </Columns>
                    <ClientSideEvents NodeClick="tree_NodeClick" />
                    <SettingsBehavior AllowFocusedNode="True" AllowSort="False" FocusNodeOnLoad="False"
                        AutoExpandAllNodes="true" />
                    <ClientSideEvents NodeClick="tree_NodeClick"></ClientSideEvents>
                </dx:ASPxTreeList>
            </td>
            <td>
                <dx:ASPxGridView ID="GV" runat="server" AutoGenerateColumns="False" DataSourceID="XD1"
                    KeyFieldName="Oid" Width="100%" ClientInstanceName="grid" Caption="商品管理" OnCustomCallback="ASPxGridView1_CustomCallback"
                    OnRowValidating="ASPxGridView1_RowValidating" OnHtmlRowPrepared="ASPxGridView1_HtmlRowPrepared">
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="30px">
                            <CellStyle HorizontalAlign="Center">
                            </CellStyle>
                            <HeaderTemplate>
                                <dx:ASPxCheckBox ID="chkAll" runat="server" ToolTip="全选/全不选本页所有行" ClientSideEvents-CheckedChanged="selectAll" />
                            </HeaderTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <CellStyle HorizontalAlign="Center" />
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn FieldName="Oid" ReadOnly="True" VisibleIndex="1" Caption="编号">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Title" VisibleIndex="4" Width="50%" Caption="标题">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataDateColumn FieldName="DisplayTime" VisibleIndex="5" Caption="发表时间">
                        </dx:GridViewDataDateColumn>
                        <dx:GridViewDataTextColumn FieldName="Author" VisibleIndex="6" Caption="作者">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewCommandColumn Caption="操作" VisibleIndex="8" Width="80px">
                            <DeleteButton Visible="True" Text="删除">
                            </DeleteButton>
                            <CancelButton Text="取消">
                            </CancelButton>
                            <UpdateButton Text="修改">
                            </UpdateButton>
                            <ClearFilterButton Visible="True">
                            </ClearFilterButton>
                            <CustomButtons>
                                <dx:GridViewCommandColumnCustomButton ID="btnEditArticle" Text="编辑">
                                </dx:GridViewCommandColumnCustomButton>
                            </CustomButtons>
                        </dx:GridViewCommandColumn>
                    </Columns>
                    <Templates>
                        <DataRow>
                            <table class="templateTable">
                                <tr>
                                    <td rowspan="4" width="30" align="center" valign="middle">
                                        <input id='chk<%#Eval("Oid") %>' type="checkbox" value='<%#Eval("Oid") %>' name="chkIds" />
                                    </td>
                                    <td align="center" rowspan="4" valign="middle" width="125">
                                        <div class="snapshot">
                                            <a href='../Gallery.aspx?Id=<%#Eval("Oid") %>' target="_blank">
                                                <img src='<%# ImageUrl(Eval("SamplePhotoId!Key")) %>' alt='<%#Eval("Title") %>' style="border: 0px" />
                                            </a>
                                        </div>
                                    </td>
                                    <td width="70">
                                        商品名称:
                                    </td>
                                    <td class="value">
                                        <%# Eval("Title") %>
                                    </td>
                                    <td width="56">
                                        发表时间:
                                    </td>
                                    <td class="value" width="120">
                                        <%# Eval("DisplayTime", "{0:yyyy-MM-dd HH:mm}") %>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="60">
                                        商品简介:
                                    </td>
                                    <td colspan="3" valign="top">
                                        <%# GetIntro( Eval("Intro")) %>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        现价:
                                    </td>
                                    <td>
                                        <table cellpadding="0" cellspacing="0" style="border: 0px">
                                            <tr style="border: 0px">
                                                <td width="150" class="value" style="border: 0px">
                                                    <%# Eval("Price") %>
                                                </td>
                                                <td width="50" style="border: 0px">
                                                    原价:
                                                </td>
                                                <td class="value" style="border: 0px">
                                                    <%# Eval("OriginalPrice")%>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td colspan="2" align="center">
                                        <a href='javascript:editInfo(<%#Eval("Oid") %>)'>编辑</a> <a href='javascript:editAlbum(<%#Eval("Oid") %>)'>
                                            管理</a> <a href='javascript:delAlbum(<%#Eval("Oid") %>)'>删除</a> <a href='javascript:setTop(<%#Eval("Oid") %>)'>
                                                置顶</a> <a href='javascript:cancelTop(<%#Eval("Oid")%>)'>取消</a>
                                    </td>
                                </tr>
                            </table>
                        </DataRow>
                        <EditForm>
                            <table class="style1">
                                <tr>
                                    <td width="70">
                                        商品名称:
                                    </td>
                                    <td style="white-space: nowrap">
                                        <dx:ASPxTextBox ID="txtTile" runat="server" Text='<%#Bind("Title")%>' Width="100%">
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        栏目:
                                    </td>
                                    <td>
                                        <table cellpadding="0" cellspacing="0" class="style1">
                                            <tr>
                                                <td width="180">
                                                    <dx:ASPxComboBox ID="cbxCategory" runat="server" DataSourceID="XD2" TextField="Title"
                                                        ValueField="Oid" Value='<%# Bind("[CategoryId!Key]") %>' ValueType="System.Int32">
                                                    </dx:ASPxComboBox>
                                                </td>
                                                <td align="right" width="60">
                                                    现价:
                                                </td>
                                                <td>
                                                    <table cellpadding="0" cellspacing="0" border="0">
                                                        <tr>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtPrice" runat="server" Text='<%#Bind("Price")%>' Width="170px">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                            <td width="50">
                                                                原价:
                                                            </td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtOriginalPrice" runat="server" Text='<%#Bind("OriginalPrice")%>'
                                                                    Width="170px">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        商品简介:
                                    </td>
                                    <td>
                                        <dx:ASPxMemo ID="txtIntro" runat="server" Height="71px" Text='<%#Bind("Intro")%>'
                                            Width="100%">
                                        </dx:ASPxMemo>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
                                            runat="server"></dx:ASPxGridViewTemplateReplacement>
                                        <dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
                                            runat="server"></dx:ASPxGridViewTemplateReplacement>
                                    </td>
                                </tr>
                            </table>
                        </EditForm>
                    </Templates>
                    <SettingsBehavior EnableRowHotTrack="True"></SettingsBehavior>
                    <SettingsPager PageSize="20">
                    </SettingsPager>
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>
    <dx:XpoDataSource ID="XD1" runat="server" ServerMode="True" TypeName="Aij1.Model.B_Series"
        DefaultSorting="SetTopTime DESC, DisplayTime DESC" 
        Criteria="AType=2">
    </dx:XpoDataSource>
    <dx:XpoDataSource ID="XD2" runat="server" TypeName="Aij1.Model.A_Category" 
        DefaultSorting="OrderId" Criteria="AType=2">
    </dx:XpoDataSource>
</asp:Content>
